import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';

import set from '@dfeidao/atom-web/local/set';


import a001 from './a001';
////////////////////////////////////////////////////////////////////////////////

export default async function a003(fd: IFeidaoAiBrowserComponent, args: Event) {
	const cc = args.currentTarget as HTMLAreaElement;
	const ccChildren = cc.children[0];
	const biaoshi = Number(ccChildren.getAttribute('biaoshi'));
	const pxmc = cc.getAttribute('data-feiao-id');
	const asc: string[] = [];
	const desc: string[] = [];
	const arr = fd.data.node.querySelectorAll('[data-feiao-paixu]');
	Array.from(arr).forEach((item) => {
		item.setAttribute('biaoshi', '0');
		item.classList.remove('icon-shang');
		item.classList.remove('icon-xiafan');
		item.classList.add('icon-shangxia');
	});
	if (biaoshi === 0) {
		ccChildren.setAttribute('biaoshi', '1');
		ccChildren.classList.remove('icon-xiafan');
		ccChildren.classList.add('icon-shang');
		ccChildren.classList.remove('icon-shangxia');
		asc.push(pxmc);
	}
	if (biaoshi === 1) {
		ccChildren.setAttribute('biaoshi', '2');
		ccChildren.classList.add('icon-xiafan');
		ccChildren.classList.remove('icon-shang');
		ccChildren.classList.remove('icon-shangxia');
		desc.push(pxmc);
	}
	if (biaoshi === 2) {
		ccChildren.classList.add('icon-shang');
		ccChildren.classList.remove('icon-xiafan');
		ccChildren.classList.remove('icon-shangxia');
		ccChildren.setAttribute('biaoshi', '1');
		asc.push(pxmc);
	}
	set(fd, 'asc', asc);
	set(fd, 'desc', desc);
	await a001(fd);
}
